using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using System.Web;

namespace AlphaWebsite.Models
{ 
    public class WeddingEventsRepository : IWeddingEventsRepository
    {
        AlphaWebsiteContext context = new AlphaWebsiteContext();

        public IQueryable<WeddingEvents> All
        {
            get { return context.WeddingEvents; }
        }

        public IQueryable<WeddingEvents> AllIncluding(params Expression<Func<WeddingEvents, object>>[] includeProperties)
        {
            IQueryable<WeddingEvents> query = context.WeddingEvents;
            foreach (var includeProperty in includeProperties) {
                query = query.Include(includeProperty);
            }
            return query;
        }

        public WeddingEvents Find(System.Guid id)
        {
            return context.WeddingEvents.Find(id);
        }

        public void InsertOrUpdate(WeddingEvents weddingevents)
        {
            if (weddingevents.WeddingEventID == default(System.Guid)) {
                // New entity
                weddingevents.WeddingEventID = Guid.NewGuid();
                context.WeddingEvents.Add(weddingevents);
            } else {
                // Existing entity
                context.Entry(weddingevents).State = EntityState.Modified;
            }
        }

        public void Delete(System.Guid id)
        {
            var weddingevents = context.WeddingEvents.Find(id);
            context.WeddingEvents.Remove(weddingevents);
        }

        public void Save()
        {
            context.SaveChanges();
        }

        public void Dispose() 
        {
            context.Dispose();
        }
    }

    public interface IWeddingEventsRepository : IDisposable
    {
        IQueryable<WeddingEvents> All { get; }
        IQueryable<WeddingEvents> AllIncluding(params Expression<Func<WeddingEvents, object>>[] includeProperties);
        WeddingEvents Find(System.Guid id);
        void InsertOrUpdate(WeddingEvents weddingevents);
        void Delete(System.Guid id);
        void Save();
    }
}